<!-- Author: Mary Llenos --> 
<!-- Last Modified: 11 Sep 2012 --> 
<?php
	include("checklogin.php");
	include("confs/upload.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Assn3_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>www.onestopjcu template</title>
<script>
document.write('<div style="display:none;"><a href="http://apycom.com/">jQuery Menu by Apycom</a></div>');
</script>
<!-- InstanceEndEditable -->

	<link href="Assn3_CSS.css" rel="stylesheet" type="text/css" />
	<link type="text/css" href="New folder/menu.css" rel="stylesheet" />
    <script type="text/javascript" src="New folder/jquery.js"></script>
    <script type="text/javascript" src="New folder/menu.js"></script>
    <script>
document.write('<div style="display:none;"><a href="http://apycom.com/">jQuery Menu by Apycom</a></div>');
</script>
</head>

<body>
<div class="container" id="top">

<div class="heads"><!-- heads -->
<div class="welcome">
<table>
<tr>
<td>
<?php  echo $_SESSION['msg2']; ?>
<a href="register.php"><?php  echo $_SESSION['msg1']; ?></a>
</td>
</tr>
</table>
</div>
</div>

<div id="menu">
  
  <ul class="menu1">
  		<li><a href="home.php" class="parent"><span>Home</span></a></li>
	
		<li><a href="member.php" class="parent"><span>Member</span></a>
			<div><ul>
    			<li><a href="member.php"><span>Member</span></a></li>            
				<li><a href="register.php"><span><?php  echo $_SESSION['msgMember']; ?></span></a></li>
    		
    		</ul></div>
		</li>           
        	
		<li><a href="Accommodation.php" class="parent"><span>Accommodation</span></a>
			<div><ul>           
				<li><a href="accommodation.php"><span>Search Room</span></a></li>
        		<li><a href="Accom_newpost.php"><span>Post New Advitisement</span></a></li>
            	<li><a href="viewpost.php"><span>View Your Posts</span></a></li>
       		
    		</ul></div>
		</li>	


		<li><a href="shopping.php" class="parent"><span>Selling Books</span></a>
			<div><ul>           
				<li><a href="shopping.php"><span>Browse Books</span></a></li>
           		<li><a href="shopping_newpost.php"><span>Post New Books</span></a></li>
             	<li><a href="view_cart.php"><span>View Your Carts</span></a></li>
       		   		
    		</ul></div>
	</li>



		<li><a href="announcement.php" class="parent"><span>Announcement</span></a>
			<div><ul>
    			<li><a href="announcement.php"><span>Announcement</span></a></li>           
        		<li><a href="new_announce.php"><span>Post New Announcement</span></a></li> 
            	<li><a href="viewmypost.php"><span>View Your Posts</span></a></li> 
                
    		</ul></div>
	</li>


        <li class="last"><a href="aboutus.php"><span>About us</span></a>
        	<div><ul>
            	<li><a href="feedback.php"><span>Feedback</span></a></li>
            </ul></div>
        
        </li>


<!-- InstanceBeginEditable name="phplogin" -->

<!-- InstanceEndEditable -->


</div><!-- menu -->


<!-- InstanceBeginEditable name="main" -->
<div class="main" style="min-height:1050px">


<!-- Flash Panel --> 
<div class="adv">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="725" height="150" id="FlashID" title="flash panel">
  <param name="movie" value="proj 2 flash/proj2flash.swf" />
  <param name="quality" value="high" />
  <param name="wmode" value="opaque" />
  <param name="swfversion" value="11.0.0.0" />
  <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don't want users to see the prompt. -->
  <param name="expressinstall" value="Scripts/expressInstall.swf" />
  <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
  <!--[if !IE]>-->
  <object type="application/x-shockwave-flash" data="proj 2 flash/proj2flash.swf" width="725" height="150">
    <!--<![endif]-->
    <param name="quality" value="high" />
    <param name="wmode" value="opaque" />
    <param name="swfversion" value="11.0.0.0" />
    <param name="expressinstall" value="Scripts/expressInstall.swf" />
    <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
    <div>
      <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
      <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
    </div>
    <!--[if !IE]>-->
  </object>
  <!--<![endif]-->
</object>
</div>
<!-- Menu of Left side --> 
<div id="main_title">
	<h4 style="margin-top:5px; margin-bottom:10px;">Accommodation</h4>
	</div>
    	<div class="next_page"><a href="accommodation.php">Accommodation<b> >></b> </a><a href="#">Edit My Post</a></div>
	<div id="vertical">
        <ul>
            <li>
                <a href="accommodation.php"><img src="image/Home48.png" width="15px" height="15px" />&nbsp;&nbsp;Accommodation</a>
            </li>
            <li>
                <a href="Accom_newpost.php"><img src="image/plus.png" width="13px" height="13px" />&nbsp;&nbsp;New Post</a>
            </li>
            <li>
                <a href="accommodation.php"><img src="image/1866012443.png" width="15px" height="15px" />&nbsp;Search Room</a>
            </li>
        </ul>
    </div>
	
    <h3 id="feedback_title">Edit My Post</h3>
	<div id="post_body">
    <!-- This form handles uploading of picture --> 
   <form name=accomForm method="post" enctype="multipart/form-data" action="editPhoto.php"><table>
	<tr>
  <td>Photo:
  </td>
  </tr>
  <tr>
  <td>
    <input type="file" name="image" id="image" onchange="validate()"/>
  <label>
    <input type="submit" name="button1" id="button1" value="Upload" />
  </label>
  <script type="text/javascript">
<!-- Validates .jpeg format pictures are selected --> 
function validate() {
	var str = document.getElementById('image').value;
	var filename = str.substring(str.indexOf("fakepath")+9);
	if ( str.indexOf(".jpg")<0) {
		alert("Please select .jpeg files only!");
		document.getElementById('filenameStr').innerHTML = "File chosen is : "+filename;
		
		document.accomForm.button1.disabled=true;
		document.formOne.signup.disabled=true;
		return false;}
	else {
		document.getElementById('filenameStr').innerHTML ="File chosen is : "+filename;
		document.accomForm.button1.disabled=false;
		document.formOne.signup.disabled=false;
	}
}
<!-- Validates postal code format entered --> 
function postalvalidate() {
			
	if ( document.getElementById('postal').value.length != 6 || isNaN(document.getElementById('postal').value)) {
		document.getElementById('errorPostal').innerHTML = " - invalid postal code";
		document.formOne.signup.disabled=true;
		return false;}
	else {
		document.formOne.signup.disabled=false;
		document.getElementById('errorPostal').innerHTML = "";
		}
	}
<!-- Validates price entered us correct --> 
function pricevalidate() {
			
	if (isNaN(document.getElementById('price').value)) {
		document.getElementById('errorPrice').innerHTML = " - invalid price";
		document.formOne.signup.disabled=true;
		return false;}
		
	else {
		document.formOne.signup.disabled=false;
		document.getElementById('errorPrice').innerHTML = "";
		}
	}
function nospaces(t){
	if(t.value.match(/\s/g)){
		alert('Sorry, you are not allowed to enter any spaces');
		t.value=t.value.replace(/\s/g,'');
	}
}

function cancel()
{

	var r=confirm("Are you sure you want to cancel?");
	if (r==true)
 	 {
 		 window.location.href = "editviewpost.php";
 	 }

}
<!-- Checks if all fields are not empty before submitting --> 
function confirmAction(form) {
        
  if (form.postal.value == "") {
    alert( "Please fill-in the accommodation postal code." );
    form.postal.focus();
    return false ;
  }
  if (form.price.value == "") {
    alert( "Please fill-in the price of the accommodation." );
    form.price.focus();
    return false ;
  }

  if (form.description.value == "") {
    alert( "Please fill-in a description of the accommodation including your contact name and number." );
    form.description.focus();
    return false ;
  }
 
  return confirm("Are you certain of the information you have filled-in?")
}
	</script>
  </td>
  <tr>
  <td><label id="filenameStr"></label>
  </td>
  </tr>
  </tr>
  <tr>
  <td align="center">
  <?php
   //retrieves data from database
  $connection=mysql_connect("localhost", "root", ""); 
  mysql_select_db("onestopjcu");
	//if this page is first accessed
	 if(isset($_REQUEST['modify'])){
  		$imgtest="select * from accommodation WHERE accom_id= '" . 		$_REQUEST['recordId'] . "'";
 	 	$showphoto=mysql_query($imgtest);
  		$shownum=mysql_num_rows($showphoto);
  		if($shownum>=1)
  		{
			$show=mysql_fetch_array($showphoto); 
			$accomId = $show['accom_id'];
			$category = $show['accom_category'];
			$district = $show['accom_district'];
			$postal = $show['accom_postal'];
			$price = $show['accom_price'];
			$descrip = $show['accom_descrip'];
			$imgfile = $show['accom_filename']; 
			if(!isset($_SESSION['accomid'])){
			$_SESSION['accomid']=$accomId;
  		}
	?>
    <img src="images/<?php echo $show['accom_filename']; ?>" width="150px" height="150px"/>
    
    
    <?php
  	}
  
  }
   //if user changed its picture this block will be run
  if($_SESSION['upload'] == "true") {
	  if(!isset($_REQUEST['mgs'])){
		  $_REQUEST['mgs']="";
	  }
	  if(!isset($_REQUEST['img'])){
		  $_REQUEST['img']="";
	  }
	  if($_REQUEST['img']!='')
  	  { 
  		$imgtest="select * from photoupload where photo_filename='".base64_decode($_REQUEST['img'])."'";
  		$showphoto=mysql_query($imgtest);
  		$shownum=mysql_num_rows($showphoto);
  		if($shownum>=1)
 	 	{
			$show=mysql_fetch_array($showphoto);  
			?>
    		<img src="images/<?php echo $show['photo_filename']; ?>" width="150px" height="150px"/>
    		<?php
	
  		}
  		 $imgtest="select * from accommodation WHERE accom_id= '" . $_SESSION['accomid'] . "'";

  		$showphoto=mysql_query($imgtest);
  		$shownum=mysql_num_rows($showphoto);
  		if($shownum>=1)
  		{	//save all fields obtained from other page
			$show=mysql_fetch_array($showphoto); 
			$accomId = $show['accom_id'];
			$category = $show['accom_category'];
			$district = $show['accom_district'];
			$postal = $show['accom_postal'];
			$price = $show['accom_price'];
			$descrip = $show['accom_descrip'];
			$imgfile = $show['accom_filename']; 
  		}
 
 	  }
  	  if($_REQUEST['mgs']=='error')
  	  {
	  	?>
      	<span style="color:#F00;"> Some Error !!!</span>
      	<?php
  	  }
  	  $_SESSION['upload'] = "change";
  }
  ?>
  </td>
  </tr>
  </table>
  </form>
 <form name=formOne action="db_accom.php?do=editpost" method="post" onSubmit="return confirmAction(this)">
    <table width="500" border="0">
      <tr >
        <td>Category
        <input type="hidden" name="id" value="<?php echo $accomId; ?>" />
        <input type="hidden" name="imgName" value="<?php echo $imgfile; ?>" />
        </td>
        </tr>
        <tr>
        <td><select id="category" name="category" style="width:207px; border:3px groove;">
         <option value="Studio" <?php if($category=='Studio') echo "selected='selected'";?>>Studio</option>
		<option value="Unit" <?php if($category=='Unit') echo "selected='selected'";?>>Unit</option>
		<option value="Room" <?php if($category=='Room') echo "selected='selected'";?>>Room</option>
        </select></td>
      <tr>
        <td>District</td>
        </tr>
        <tr>
        <td><select name="district" style="width:207px; border:3px groove;">
        <option value="Ang Mo Kio" <?php if($district=='Ang Mo Kio') echo "selected='selected'";?>>Ang Mo Kio</option>
		<option value="City Hall" <?php if($district=='City Hall') echo "selected='selected'";?>>City Hall</option>
		<option value="Dhoby Gaut" <?php if($district=='Dhoby Gaut') echo "selected='selected'";?>>Dhoby Gaut</option>
        <option value="Newton" <?php if($district=='Newton') echo "selected='selected'";?>>Newton</option>
		<option value="Novena" <?php if($district=='Novena') echo "selected='selected'";?>>Novena</option>
		<option value="Sembawang" <?php if($district=='Sembawang') echo "selected='selected'";?>>Sembawang</option>
		<option value="Toa Payoh" <?php if($district=='Toa Payoh') echo "selected='selected'";?>>Toa Payoh</option>
		<option value="Upper Thomson" <?php if($district=='Upper Thomson') echo "selected='selected'";?>>Upper Thomson</option>
        </select></td>
      </tr>
      <tr>
        <td>Postal</td>
        </tr>
        <tr>
        <td><input id="postal" type="text" name="postal" style="width:200px; border:3px groove; height:18px;" value="<?php echo $postal?>" onchange="postalvalidate()" onkeyup="nospaces(this)"/><label style="color: #F00;" id="errorPostal"></label></td>
        </tr>
    <tr>
        <td>Price</td>
        </tr>
        <tr>
        <td><input id="price" type="text" name="price" style="width:200px; border:3px groove; height:18px;" value="<?php echo $price?>" onchange="pricevalidate()" onkeyup="nospaces(this)"/><label style="color: #F00;" id="errorPrice"></label></td>
        </tr>
        <td>Description</td>
        </tr>
        <tr>
        <td><textarea id="description" name="description" rows="5" cols="45" style="border:3px groove;"><?php echo $descrip ?></textarea>
        
        </td>
      <tr>
        <td>
        <input type="button" name="Cancel" value="Cancel" onClick="cancel();">
        <input type="submit" name="signup" value="Modify" /></td>
      </tr>
    </table>


</form>

<em></em> </div>	
    
	<div class="mainright">
    	<br/>
<div class="titlebar2">
<img src=" " style="padding-right:5px; padding-left:2px; padding-top:2px; float:left">
<a style="color:#ffffff;text-decoration:none;font-family:Arial, Helvetica, sans-serif; font-size:13px;" href="http://www.exchangerates.org.uk/Singapore-Dollar-SGD-currency-table.html" target="_new" title="Singapore Dollar Exchange Rate">Weather Forecast</a></div><div style="padding:0px; text-align:left;">
</div>

<div style="width:295px; height:200px; margin-bottom:2px;">
    <object type="application/x-shockwave-flash" data="http://swf.yowindow.com/wimo/hpPal/hpPal.swf" width="295" height="200">
    	<param name="movie" value="http://swf.yowindow.com/wimo/hpPal/hpPal.swf"/>
    	<param name="allowfullscreen" value="true"/>
    	<param name="wmode" value="opaque"/>
    	<param name="bgcolor" value="#FFFFFF"/>
    	<param name="flashvars" 
    	value="location_id=gn:1880252&amp;location_name=Singapore&amp;landscape=airport&amp;time_format=12&amp;us=metric&amp;background=#FFFFFF&amp;copyright_bar=false"
    />
        <a href="http://yowindow.com/weatherwidget.php"
        style="width:300px;height:200px;display: block;text-indent: -50000px;font-size: 0px;background:#DDF url(http://yowindow.com/img/logo.png) no-repeat scroll 50% 50%;"
        >Free Weather Widget</a>
    </object>
</div>
<div class="titlebar2">
<img src=" " style="padding-right:5px; padding-left:2px; padding-top:2px; float:left">
<a style="color:#ffffff;text-decoration:none;font-family:Arial, Helvetica, sans-serif; font-size:13px;" href="http://www.exchangerates.org.uk/Singapore-Dollar-SGD-currency-table.html" target="_new" title="Singapore Dollar Exchange Rate">Exchange Rate</a></div><div style="padding:0px; text-align:left;">
</div><!-- titlebar -->
<div style="width:280px;text-align:left;padding-left:18px;background:#EEE;font-family:Arial, Helvetica, sans-serif;font-size:13px;color:#ffffff;font-weight:bold;vertical-align:middle;">

<script type="text/javascript">	
var dcf = 'SGD';
var dct = 'EUR';
var mc = '2D6AB4';
var mbg = 'f0f0f0';
var tc = 'ffffff';
var f = 'arial';
var fc = '000000';
var tz = 'userset';

</script><script type="text/javascript" src="http://www.currency.me.uk/remote/ER-TCS-1.php"></script></div>

		
    </div>


</div><!-- main -->
<!-- InstanceEndEditable -->


<div class="footer"> 
<div style="margin-left:10px; float:left; font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:12px; color:#FFF; width:430px; height:12px; margin-top:16px;">Copyright &copy; 2012 www.onestopjcu.com
</div>

<div style="margin-left:50px; float:left; font-family:Arial, Helvetica,sans-serif; font-weight:bold; font-size:11px; width:100px; height:12px; margin-top:16px;"><a href="#top" style="color:#FFF; text-decoration: none;">Return to Top</a>
</div>

<ul>
<li><a href="feedback.php">Feedback</a></li>
<li><a href="FAQ.php">FAQ</a></li>
<li><a href="aboutus.php" style="margin-right:24px;">About Us</a></li>
<li><a href="aboutus.php" style="margin-right:24px;">Contact Us</a></li>
</ul>




</div><!-- footer -->
</div><!-- container -->
</body>
<!-- InstanceEnd --></html>
